import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { viteMockServe } from "vite-plugin-mock";
import { fileURLToPath, URL } from "node:url";
import Components from "unplugin-vue-components/vite";
export default defineConfig(({ mode }) => {
  console.log(mode);
  // production 模式下不开启 mock
  // development 模式下开启 mock
  const isDevelopment = mode === "development";

  return {
    plugins: [
      vue(),
      viteMockServe({
        mockPath: "mock",
        enable: true, // ✅ 正确判断是否是开发环境
      }),
      Components({
        /* options */
      }),
    ],
    server: {
      open: true,
    },
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
    },
  };
});
